// This file is a part of Funky C++.
// Copyright (C) 2011  Valentin David
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
#ifndef STRETCH_FACTOR_HH
# define STRETCH_FACTOR_HH

namespace fast {
  template <size_t N>
  struct stretch_factor_octave {
    static constexpr float value = 2. * stretch_factor_octave<N-1>::value;
  };

  template <>
  struct stretch_factor_octave<0u> {
    static constexpr float value = 1.;
  };

  template <size_t N>
  struct stretch_factor;

  template <size_t N>
  struct stretch_factor_note {
    static constexpr float value =
      stretch_factor<(N+7)>::value * 2. / 3.;
  };

  template <>
  struct stretch_factor_note<0u> {
    static constexpr float value = 1.;
  };

  template <size_t N>
  struct stretch_factor {
    static constexpr float value = stretch_factor_octave<N/12>::value *
      stretch_factor_note<N%12>::value;
  };

}

#endif
